import { createRouter, createWebHistory } from "vue-router";
import Index from '../page/index.vue'
const router = createRouter({
    // 提供的一种基于浏览器 history API 的路由模式，它使用了 HTML5 中的 history.pushState 和 history.replaceState 方法来实现路由跳转
    history: createWebHistory(),
    routes: [{
        path: '/',
        redirect: '/index',
        component: Index,
        meta: { title: '首页' },
        children: [{
            path: '/index',
            name: 'index',
            component: () =>
                import ('../page/subpage/index.vue'),
            meta: { title: '首页' }
        }, {
            path: '/category',
            name: 'category',
            component: () =>
                import ('../page/subpage/category.vue'),
            meta: { title: '分类管理' }
        }, {
            path: '/books',
            name: 'books',
            component: () =>
                import ('../page/subpage/books.vue'),
            meta: { title: '图书管理' }
        }, {
            path: '/setting',
            name: 'setting',
            component: () =>
                import ('../page/subpage/setting.vue'),
            meta: { title: '个人中心' }
        }]
    }, {
        path: '/login',
        name: 'login',
        component: () =>
            import ('../page/login.vue'),
        meta: { title: '登录' }
    }]
})


export default router